<script setup lang="ts">
const userInfo = {
  name: 'Admin',
  avatar: 'https://via.placeholder.com/40', // 可替换为真实头像 URL
}

const router = useRouter()
function logout() {
  router.replace('/login')
}
</script>

<template>
  <div class="user-header">
    <div class="left">
      <span class="title">My Admin 系统</span>
    </div>
    <div class="right">
      <el-dropdown>
        <span class="el-dropdown-link">
          <el-avatar :size="45" :src="userInfo.avatar" style="vertical-align: middle" />
          <span class="username">{{ userInfo.name }}</span>
        </span>
        <template #dropdown>
          <el-dropdown-menu>
            <el-dropdown-item>个人中心</el-dropdown-item>
            <el-dropdown-item divided @click="logout">
              退出登录
            </el-dropdown-item>
          </el-dropdown-menu>
        </template>
      </el-dropdown>
    </div>
  </div>
</template>

<style scoped lang="scss">
.user-header {
  height: 60px;
  background-color: #fff;
  border-bottom: 1px solid #ebeef5;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  .title {
    font-size: 18px;
    font-weight: bold;
  }
  .username {
    margin-left: 8px;
    font-size: 14px;
    color: #333;
  }
}
</style>
